﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ResetPassword : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    /// <summary>
    /// 密码重置
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(TxtLogin.Text.Trim()))
        {
            CommenMethod.GetJavaScript("请输入登录密码！");
            return;
        }
        if (string.IsNullOrEmpty(TxtLogin1.Text.Trim()))
        {
            CommenMethod.GetJavaScript("请输入确认登录密码！");
            return;
        }
        if (TxtLogin.Text.Trim() != TxtLogin1.Text.Trim())
        {
            CommenMethod.GetJavaScript("新登录密码和确认密码不一致！");
            return;
        }
        if (string.IsNullOrEmpty(TxtPay.Text.Trim()))
        {
            CommenMethod.GetJavaScript("请输入二级密码！");
            return;
        }
        if (string.IsNullOrEmpty(TxtPay1.Text.Trim()))
        {
            CommenMethod.GetJavaScript("请输入确认二级密码！");
            return;
        }
        if (TxtPay.Text.Trim() != TxtPay1.Text.Trim())
        {
            CommenMethod.GetJavaScript("新二级密码和确认二级密码不一致！");
            return;
        }
        string userId = Request.QueryString["userId"];
        try
        {
            BLL.User.UpdatePassword(userId, CommenMethod.md5(TxtLogin.Text.Trim(), 32), CommenMethod.md5(TxtPay.Text.Trim(), 32));
            CommenMethod.GetJavaScript("密码重置成功！","login.aspx");
        }
        catch (Exception ex)
        {
            CommenMethod.GetJavaScript("密码重置失败！"); ;
        }
    }
}